• Syntax:
      SELECT <exp>
      CASE <exp1>             // multiple CASEs can occur
        <statements1>
      [ DEFAULT
        <statements> ]
      ENDSELECT [ <list> ]
    

    <exp> is a source expression which will be compared with each of <exp1> expressions. <exp1> can contain multiple expressions. (See below.) If atleast one of them will be the same as result of <exp>, <statements1> will be processed. If no, next CASE will be tested. If no CASE matched the <exp>, <statements> (after DEFAULT) will be processed.

  • Multiple expressions:
    Single expressions must be separated by a comma (,):
      CASE <a>,<b>; <statements>
    

    If <exp> equals to <a> or <b>, <statements> will be processed.

  • Arrays in expressions:
    <exp1> can contain also arrays, which are made with TO keyword:
      CASE <a> TO <b>; <statements>
    

    where <a> is bottom and <b> is top of the array. If <exp> fits to the array <statements> will be processed.

  • Examples:
      SELECT age
      CASE 0 TO 17
        PrintF('Young\n')
      CASE 18 TO 50
        PrintF('Adult\n')
      CASE 51 TO 120
        PrintF('Old\n')
      DEFAULT
        PrintF('What???\n')
      ENDSELECT
    
      name:=SELECT Person.ID
        CASE 1 IS 'Paul'
        CASE 2 IS 'Jenny'
        CASE 3 IS 'Peter'
        CASE 4 IS 'Mark'
        ENDSELECT 'unknown'